Python3 中的最大整数和最大浮点数 | 您所在的位置:网站首页 › python 最大整数 › Python3 中的最大整数和最大浮点数 |
Python中的最大整数 Python中可以通过sys模块来得到int的最大值. python2中使用的方法是 import sysmax = sys.maxintprint (max) python3中使用的方法是: import sysmax = sys.maxsizeprint (max) Python中获得最大浮点数 方法一:使用sys模块 >>> import sys>>> sys.float_infosys.floatinfo(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.2204460492503131e-16, radix=2, rounds=1)>>> sys.float_info.max1.7976931348623157e+308 方法二:使用float函数 import numpy print numpy.finfo(numpy.float)Machine parameters for float64---------------------------------------------------------------------precision= 15 resolution= 1.0000000000000001e-15machep= -52 eps= 2.2204460492503131e-16negep = -53 epsneg= 1.1102230246251565e-16 minexp= -1022 tiny= 2.2250738585072014e-308maxexp= 1024 max= 1.7976931348623157e+308nexp = 11 min= -max--------------------------------------------------------------------- 参考链接 https://stackoverflow.com/questions/8216088/how-to-check-the-size-of-a-float-in-python |
CopyRight 2018-2019 实验室设备网 版权所有 |